package au.com.handsunited.model.validators.contactinfo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

import au.com.handsunited.model.ContactInfo;
import au.com.handsunited.model.validators.address.OrganisationContactInfoAddressValidator;


/**
 * @author arunda
 *
 */
public class OrganisationContactInfoValidator extends ContactInfoValidator {

	private static Logger logger = LoggerFactory.getLogger(OrganisationContactInfoValidator.class);

	/**
	 *
	 */
	public OrganisationContactInfoValidator(OrganisationContactInfoAddressValidator addressValidator) {
		super(addressValidator);
	}

	/**
	 * @see au.com.handsunited.model.validators.contactinfo.ContactInfoValidator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	@Override
	public void validate(Object target, Errors errors) {

		super.validate(target, errors);

		ContactInfo contactInfo = (ContactInfo) target;

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "organisation.contactInfo.name.required", "Contact Name is required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "organisation.contactInfo.emailAddress.required", "Email Address is required");

	}

}
